﻿

namespace Hidistro.UI.Common.Controls
{
    using Hidistro.Core;
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    public class GotoReview : HyperLink
    {
        public const string TagID = "GotoReview";

        public GotoReview()
        {
            base.ID = "GotoReview";
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if ((this.ProductId != null) && (this.ProductId != DBNull.Value))
            {
                if (this.IsGroupBuyProduct)
                {
                    base.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("groupBuyProductDetails", new object[] { this.ProductId });
                }
                else if (this.IsCountDownProduct)
                {
                    base.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("countdownProductsDetails", new object[] { this.ProductId });
                }
                else if (this.IsUnSale)
                {
                    base.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("unproductdetails", new object[] { this.ProductId });
                }
                else
                {
                    base.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { this.ProductId, this.CategoryUrl });
                }
            }
            if ((!this.ImageLink && (this.ProductId != null)) && (this.ProductId != DBNull.Value))
            {
                if (this.StringLenth.HasValue && (this.ProductName.ToString().Length > this.StringLenth.Value))
                {
                    base.Text = "去评价";
                }
                else
                {
                    base.Text = "去评价";
                }
            }
            base.Target = "_self";
            base.Render(writer);
        }

        public bool ImageLink { get; set; }

        public bool IsCountDownProduct { get; set; }

        public bool IsGroupBuyProduct { get; set; }

        public bool IsUnSale { get; set; }

        public object ProductId { get; set; }

        public object ProductName { get; set; }

        public int? StringLenth { get; set; }

        public string CategoryUrl { get; set; }
    }
}
